package com.ld.admin.util.daliySentence.impl;

import org.apache.commons.lang.math.RandomUtils;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import com.ld.admin.util.daliySentence.DaliySentence;
import com.ld.shieldsb.common.core.util.JsoupUtil;

/**
 * 
 * one一个
 * 
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2020年1月8日 下午2:12:23
 *
 */
public class DaliySentenceOne implements DaliySentence {
    // 未使用的 https://www.dailyenglishquote.com
    public static final String URL_ONE = "http://wufazhuce.com/"; // one一个的网址

    @Override
    public String getSentence() {
        String content = null;
        Document document = JsoupUtil.getRemoteURLDocument(URL_ONE, null);
        if (document != null) {
            Elements contentCs = document.select("div.fp-one-cita");
            Elements images = document.select(".fp-one-imagen"); // 图片
            int random = RandomUtils.nextInt(20) % contentCs.size();
            content = "<img src=\"" + images.get(random).attr("src") + "\" width='270' >" + "<br/>"; // height='180'
            content += contentCs.get(random).select("a").text() + "【来自<a href='http://wufazhuce.com' target='_blank'>「ONE · 一个」</a>】";
        }
        return content;
    }

}
